from configparser import ConfigParser


def get_config(filename='../server_config.ini', section='postgresql'):
    """
    获取配置信息
    :param filename: 配置文件（默认server_info.ini文件)
    :param section: 配置模块（默认postgresql数据库配置）
    :return: 指定配置模块下的所有配置项
    """
    parser = ConfigParser()
    parser.read(filename)
    configs = {}
    if parser.has_section(section):
        params = parser.items(section)
        for param in params:
            configs[param[0]] = param[1]
    else:
        raise Exception('Section {0} not found in the {1} file'.format(section, filename))
    return configs
